/**
 *****************************************************************************
 * @file
 * @brief
 * @author Moon
 * @version V1.0.0
 * @date 2021/05/19
 ****************************************************************************
 参照参数管理方案3.0 地址划分参考表V1.0.0
 */
#ifndef _STORAGE_ADDR_H
#define _STORAGE_ADDR_H

/* Public defines -----------------------------------------------------------*/
/*
 * 是否使用外部存储
 * USE_INTERNAL_FLASH
 * USE_EXTERNAL_FLASH
 * USE_EXTERNAL_FRAM
*/
#define USE_EXTERNAL_FRAM

/*
 * MCU Flash大小
 * FLASH_SIZE_64K
 * FLASH_SIZE_128K
 * FLASH_SIZE_256K
 * FLASH_SIZE_512K
 * FLASH_SIZE_1M
 * FLASH_SIZE_2M
 */
#define FLASH_SIZE_1M

#if defined(USE_EXTERNAL_FRAM)
    #define FRAM_DEFAULT_MODE		(0)
	#define FRAM_NORMAL_MODE		(1)
#endif

#if !defined(USE_INTERNAL_FLASH) && !defined(USE_EXTERNAL_FLASH) && !defined(USE_EXTERNAL_FRAM)
    #error Missing definition: storage type must be defined.
#endif

#if !defined(FLASH_SIZE_64K) && !defined(FLASH_SIZE_128K) && !defined(FLASH_SIZE_256K) && !defined(FLASH_SIZE_512K) && !defined(FLASH_SIZE_1M) && !defined(FLASH_SIZE_2M)
    #error Missing definition: internal flash size must be defined.
#endif

#if defined(USE_INTERNAL_FLASH)     // 使用内部存储
    #if defined(FLASH_SIZE_64K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x6400)    // 25K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x6400)    // 25K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x10000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_128K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xE400)    // 57K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0xE400)    // 57K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x20000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_256K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x1E400)   // 121K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x1E400)   // 121K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x40000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_512K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x3E400)   // 249K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x3E400)   // 249K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x80000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_1M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x4000)    // 16K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x4000)    // 16K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x4000)    // 16K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x4000)    // 16K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x6F800)   // 446K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x6F800)   // 446K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x100000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_2M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x20000)   // 128K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x20000)   // 128K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x20000)   // 128K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x20000)   // 128K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xCF800)   // 830K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0xCF800)   // 830K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x200000)
            #error Device flash space is exceeded.
        #endif

    #endif

#elif defined(USE_EXTERNAL_FLASH)     // 使用外部Flash
    #if defined(FLASH_SIZE_64K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xC800)    // 50K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x10000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0xC000)    // 48K

    #elif defined(FLASH_SIZE_128K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x1C800)    // 114K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x20000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0x1C000)    // 112K

    #elif defined(FLASH_SIZE_256K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x3C800)   // 242K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x40000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0x3C800)    // 242K

    #elif defined(FLASH_SIZE_512K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x800)     // 2K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x7C800)   // 498K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x80000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0x7C000)   // 496K

    #elif defined(FLASH_SIZE_1M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x4000)    // 16K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x4000)    // 16K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x4000)    // 16K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x4000)    // 16K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xDF000)   // 892K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x100000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0xDF000)   // 892K

    #elif defined(FLASH_SIZE_2M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x20000)   // 128K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x20000)   // 128K

        #define STORAGE_PARM_SYSTEM_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_PARM_SYSTEM_SIZE    (0x20000)   // 128K

        #define STORAGE_PARM_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
        #define STORAGE_PARM_APP_SIZE       (0x20000)   // 128K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_APP_BASE + STORAGE_PARM_APP_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x19F000)   // 1660K

        #if (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x200000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x19F000)   // 1660K

    #endif

#elif defined(USE_EXTERNAL_FRAM)     // 使用外部PRAM
    #if defined(FLASH_SIZE_64K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x6C00)    // 27K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x6C00)    // 27K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x10000)
            #error Device flash space is exceeded.
        #endif
        
    #elif defined(FLASH_SIZE_128K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xEC00)    // 59K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0xEC00)    // 59K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x20000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_256K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x1EC00)   // 123K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x1EC00)   // 123K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x40000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_512K)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x2000)    // 8K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x800)     // 2K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x3EC00)    // 251K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0x3EC00)    // 251K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x80000)
            #error Device flash space is exceeded.
        #endif

    #elif defined(FLASH_SIZE_1M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x20000)    // 128K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x20000)    // 128K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0x7C000)    // 496K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x100000)
            #error Device flash space is exceeded.
        #endif

        #define STORAGE_DOWNLOAD_BASE       (0x00000000)
        #define STORAGE_DOWNLOAD_SIZE       (0x7C000)   // 496K

        #define STORAGE_LOG_BASE            (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE)
        #define STORAGE_LOG_SIZE            (0x100000)  // 1M        
        
    #elif defined(FLASH_SIZE_2M)
        #define STORAGE_BOOTLOADER_BASE     (0x08000000)
        #define STORAGE_BOOTLOADER_SIZE     (0x20000)    // 128K

        #define STORAGE_PARM_UPATAE_BASE    (STORAGE_BOOTLOADER_BASE + STORAGE_BOOTLOADER_SIZE)
        #define STORAGE_PARM_UPATAE_SIZE    (0x20000)    // 128K

        #define STORAGE_APPLICATION_BASE    (STORAGE_PARM_UPATAE_BASE + STORAGE_PARM_UPATAE_SIZE)
        #define STORAGE_APPLICATION_SIZE    (0xE0000)    // 896K

        #define STORAGE_DOWNLOAD_BASE       (STORAGE_APPLICATION_BASE + STORAGE_APPLICATION_SIZE)
        #define STORAGE_DOWNLOAD_SIZE       (0xE0000)    // 896K

        #if (STORAGE_DOWNLOAD_BASE + STORAGE_DOWNLOAD_SIZE) > (STORAGE_BOOTLOADER_BASE + 0x200000)
            #error Device flash space is exceeded.
        #endif
        
    #endif

    // 外部PRAM地址统一定义
    #define STORAGE_PARM_DEFAULT_SYSTEM_BASE    (0x00000000)
    #define STORAGE_PARM_DEFAULT_SYSTEM_SIZE    (0x800)     // 2K

    #define STORAGE_PARM_SYSTEM_BASE            (STORAGE_PARM_DEFAULT_SYSTEM_BASE + STORAGE_PARM_DEFAULT_SYSTEM_SIZE)
    #define STORAGE_PARM_SYSTEM_SIZE            (0x800)     // 2K

    #define STORAGE_PARM_DEFAULT_APP_BASE       (STORAGE_PARM_SYSTEM_BASE + STORAGE_PARM_SYSTEM_SIZE)
    #define STORAGE_PARM_DEFAULT_APP_SIZE       (0x800)     // 2K

    #define STORAGE_PARM_APP_BASE               (STORAGE_PARM_DEFAULT_APP_BASE + STORAGE_PARM_DEFAULT_APP_SIZE)
    #define STORAGE_PARM_APP_SIZE               (0x800)     // 2K

#endif

/* Public Struct -----------------------------------------------------------*/

/* Public enum -----------------------------------------------------------*/

/* Public Variable ---------------------------------------------------------*/
//Pointer

//Array

//Const

/* Pubilc function prototypes -----------------------------------------------*/

#endif /* _STORAGE_ADDR_H */
